﻿namespace CodingExercises._1_25;

public class UpdateHighestScore
{
    // 追踪玩家的最高得分
    public static void Method(Player? player, int newScore)
    {
        if (player?.Statistics is null)
        {
            return;
        }

        player.Statistics.HighestScore ??= newScore;
        if (player.Statistics.HighestScore < newScore)
        {
            player.Statistics.HighestScore = newScore;
        }
    }
}

public class Player
{
    public Statistics? Statistics { get; set; }
}

public class Statistics
{
    public int? HighestScore { get; set; }
}